home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / WindowMaker / WINGs / wmquery.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-29  |  1.7 KB  |  100 lines

  1.  
  2. /*
  3.  * Author: Len Trigg <trigg@cs.waikato.ac.nz> 
  4.  */
  5.  
  6.  
  7. #include "WINGs.h"
  8.  
  9. #include <unistd.h>
  10. #include <stdio.h>
  11.  
  12. #include "logo.xpm"
  13.  
  14.  
  15.  
  16.  
  17. void
  18. wAbort()
  19. {
  20.     exit(1);
  21. }
  22.  
  23. char *ProgName;
  24.  
  25. void usage(void)
  26. {
  27.   fprintf(stderr,
  28.       "usage:\n"
  29.       "\t%s [-options]\n"
  30.       "\n"
  31.       "options:\n"
  32.       "  -i <str>\tInitial entry contents (default none)\n"
  33.       "  -p <str>\tPrompt message (default none)\n"
  34.       "  -t <str>\tQuery window title (default none)\n"
  35.       "\n"
  36.       "information:\n"
  37.       "\t%s pops up a WindowMaker style input panel.\n"
  38.       "\n"
  39.       "version:\n"
  40.       "\t%s\n"
  41.       ,ProgName,ProgName,__DATE__
  42.       );
  43.   exit(0);
  44. }
  45.  
  46. int main(int argc, char **argv)
  47. {
  48.   Display *dpy = XOpenDisplay("");
  49.   WMScreen *scr;
  50.   WMPixmap *pixmap;
  51.   char *title = NULL;
  52.   char *prompt = NULL;
  53.   char *initial = NULL;
  54.   char *result = NULL;
  55.   int ch;
  56.   extern char *optarg;
  57.   extern int optind;
  58.  
  59.   WMInitializeApplication("WMQuery", &argc, argv);
  60.              
  61.   ProgName = argv[0];   
  62.  
  63.   if (!dpy) {
  64.     puts("could not open display");
  65.     exit(1);
  66.   }
  67.     
  68.   while((ch = getopt(argc, argv, "i:hp:t:")) != -1)
  69.     switch(ch) 
  70.     { 
  71.     case 'i':
  72.       initial = optarg;
  73.       break;
  74.     case 'p':
  75.       prompt = optarg;
  76.       break;
  77.     case 't':
  78.       title = optarg;
  79.       break;
  80.     default:
  81.       usage();
  82.     }
  83.  
  84.   for(; optind <argc; optind++)
  85.     usage();
  86.  
  87.  
  88.   scr = WMCreateSimpleApplicationScreen(dpy);
  89.  
  90.   pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
  91.     
  92.   WMSetApplicationIconImage(scr, pixmap); WMReleasePixmap(pixmap);
  93.  
  94.   if ((result = WMRunInputPanel(scr, NULL, title, prompt, initial, "OK", "Cancel")) != NULL)
  95.     printf("%s\n", result);
  96.   else
  97.     printf("\n");
  98.   return 0;
  99. }
  100.